//
//  HMUPgradeViewModel.m
//  HowToDo
//
//  Created by 宋轩 on 17/1/5.
//  Copyright © 2017年 KY. All rights reserved.
//

#import "HMUPgradeViewModel.h"
#import "HMNetWorkTool.h"
#import "HMUPgradeModel.h"
#import <YYModel.h>
#import "HMSuitableModel.h"

@implementation HMUPgradeViewModel

//+ (void)getUPgradeModeWithID:(NSNumber *)tid Finished:(void(^)(NSArray *))finishedBlock Failed:(void(^)(NSError* error))failedBlock
//{
//    [[HMNetWorkTool sharedTool] requestDetailsJsonDataWithID:tid Finished:^(id responseObject) {
//        NSDictionary *jsonDict = responseObject;
//        
//        NSArray *jsonAray = jsonDict[@"data"][@"last_items"];
////        NSDictionary *dic = jsonDict[@"data"];
//        
////        NSDictionary *dicModel = [NSDictionary yy_modelDictionaryWithClass:[HMUPgradeModel class]json:dic];
//        
//        
//        
//        NSArray *newList = [NSArray yy_modelArrayWithClass:[HMUPgradeModel class] json:jsonAray];
//        
//        finishedBlock(newList);
//    } Failed:^(NSError *error) {
//        failedBlock(error);
//    }];
//}

+ (void)getUPgradeModeWithID:(NSNumber *)tid Finished:(void(^)(id))finishedBlock Failed:(void(^)(NSError* error))failedBlock
{
    [[HMNetWorkTool sharedTool] requestDetailsJsonDataWithID:tid Finished:^(id responseObject) {
        NSDictionary *jsonDict = responseObject;
        NSDictionary *dic = jsonDict[@"data"];
        HMSuitableModel *model = [HMSuitableModel yy_modelWithDictionary:dic];
        
        model.last_items = [NSArray yy_modelArrayWithClass:[HMUPgradeModel class]json:dic[@"last_items"]];
        
        finishedBlock(model);
    } Failed:^(NSError *error) {
        failedBlock(error);
    }];
}
@end
